package com.itheima.sevrice.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.bean.User;
import com.itheima.dao.UserDao;
import com.itheima.sevrice.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    /**
     * 添加用户
     *
     * @param user
     * @return
     */
    @Override
    public int addUser(User user) {
        return userDao.insert(user);
    }

    /**
     * 根据phone 号码 查询是否有这个用户
     *
     * @param Phone
     * @return
     */
    @Override
    public User findByPhone(String Phone) {
        //构建条件对象
        LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();
        //追加条件
        lqw.eq(User::getPhone,Phone);
        //执行条件
        return userDao.selectOne(lqw);
    }



}
